<template>
    <div class="pin" id="myChart1"></div>
    
    <!-- <div class="pin" id="myChart2"></div>
    <div class="pin" id="myChart3"></div> -->
</template>
<script>
import echarts from 'echarts'
export default {
  props: {
    num1: {
      type: Number,
      default: 0
    },
    // num2: {
    //   type: Number,
    //   default: 0
    // },
    // num3: {
    //   type: Number,
    //   default: 0
    // }
  },
  data() {
    return {
      myChart1: null,
    //   myChart2: null,
    //   myChart3: null
    }
  },
  watch: {
    num1(val) {
      this.myChart1.setOption(this.setOption1())
    },
    // num2(val) {
    //   this.myChart2.setOption(this.setOption2())
    // },
    // num3(val) {
    //   this.myChart3.setOption(this.setOption3())
    // }
  },
  mounted() {
    this.myChart1 = echarts.init(document.getElementById('myChart1'))
    this.myChart1.setOption(this.setOption1())

    // this.myChart2 = echarts.init(document.getElementById('myChart2'))
    // this.myChart2.setOption(this.setOption2())

    // this.myChart3 = echarts.init(document.getElementById('myChart3'))
    // this.myChart3.setOption(this.setOption3())
  },
  methods: {
    setOption1() {
      let option = {
        title: [
          {
            text: '',
            x: 'center',
            top: '55%',
            textStyle: {
              color: '#fdf914',
              fontSize: 18,
              fontWeight: '100'
            }
          },
          {
            text: this.num1 + '%',
            x: 'center',
            top: '40%',
            textStyle: {
              fontSize: '30',
              color: '#fdf914',
              fontFamily: 'Lato',
              foontWeight: '500'
            }
          }
        ],
        polar: {
          radius: ['55%', '65%'],
          center: ['50%', '50%']
        },
        angleAxis: {
          max: 100,
          show: false
        },
        radiusAxis: {
          type: 'category',
          show: true,
          axisLabel: {
            show: false
          },
          axisLine: {
            show: false
          },
          axisTick: {
            show: false
          }
        },
        series: [
          {
            name: '',
            type: 'bar',
            roundCap: true,
            barWidth: 60,
            showBackground: true,
            backgroundStyle: {
              color: 'rgba(66, 66, 66, .3)'
            },
            data: [this.num1],
            coordinateSystem: 'polar',

            itemStyle: {
              normal: {
                color: new echarts.graphic.LinearGradient(0, 1, 0, 0, [
                  {
                    offset: 1,
                    color: 'rgb(53, 255, 178)'
                  },
                  {
                    offset: 0.5,
                    color: 'rgb(255, 242, 53)'
                  },
                  {
                    offset: 0,
                    color: 'rgb(255, 104, 53)'
                  }
                ])
              }
            }
          },
          {
            type: 'gauge',
            name: '',
            radius: '80%',
            startAngle: '0',
            endAngle: '-359.99',
            splitNumber: '200',
            center: ['50%', '50%'],
            pointer: {
              show: false
            },
            title: {
              show: false
            },
            detail: {
              show: false
            },
            data: [
              {
                value: 95,
                name: ''
              }
            ],
            axisLine: {
              lineStyle: {
                width: 50,
                opacity: 0
              }
            },
            axisTick: {
              show: false
            },
            splitLine: {
              show: true,
              length: 13,
              lineStyle: {
                color: {
                  type: 'linear',
                  x: 1,
                  y: 0,
                  x2: 0,
                  y2: 0,
                  colorStops: [
                    {
                      offset: 0,
                      color: '#111'
                    },
                    {
                      offset: 0.5,
                      color: 'rgb(71, 255, 252)'
                    },
                    {
                      offset: 1,
                      color: '#111'
                    }
                  ],
                  globalCoord: false
                },
                width: 1,
                type: 'solid'
              }
            },
            axisLabel: {
              show: false
            }
          },
          {
            name: '',
            type: 'pie',
            startAngle: 90,
            radius: ['65%', '68%'],
            hoverAnimation: false,
            center: ['50%', '50%'],
            itemStyle: {
              normal: {
                labelLine: {
                  show: false
                },
                color: 'rgba(66, 66, 66, .4)',
                shadowBlur: 10,
                shadowColor: 'rgba(253, 249, 20, .3)'
              }
            },
            data: [
              {
                value: 100
              }
            ]
          },
          {
            name: '',
            type: 'pie',
            startAngle: 90,
            radius: ['62.5%', '64%'],
            hoverAnimation: false,
            center: ['50%', '50%'],
            itemStyle: {
              normal: {
                labelLine: {
                  show: false
                },
                color: 'rgba(66, 66, 66, .3)',
                shadowBlur: 10,
                shadowColor: 'rgba(253, 249, 20, .3)'
              }
            },
            data: [
              {
                value: 100
              }
            ]
          },
          {
            name: '',
            type: 'pie',
            startAngle: 90,
            radius: ['64.5%', '65.8%'],
            hoverAnimation: false,
            center: ['50%', '50%'],
            itemStyle: {
              normal: {
                labelLine: {
                  show: false
                },
                color: 'rgba(66, 66, 66, .2)',
                shadowBlur: 10,
                shadowColor: 'rgba(253, 249, 20, .3)'
              }
            },
            data: [
              {
                value: 100
              }
            ]
          },
          {
            name: '',
            type: 'pie',
            startAngle: 90,
            radius: ['66.5%', '67.5%'],
            hoverAnimation: false,
            center: ['50%', '50%'],
            itemStyle: {
              normal: {
                labelLine: {
                  show: false
                },
                color: 'rgba(66, 66, 66, .1)',
                shadowBlur: 10,
                shadowColor: 'rgba(253, 249, 20, .3)'
              }
            },
            data: [
              {
                value: 100
              }
            ]
          },
          {
            name: '',
            type: 'custom',
            coordinateSystem: 'none',
            renderItem: (params, api) => {
              return {
                type: 'arc',
                shape: {
                  cx: api.getWidth() / 2,
                  cy: api.getHeight() / 2,
                  r: (Math.min(api.getWidth(), api.getHeight()) / 2) * 0.545,
                  startAngle: ((0 + this.num1) * Math.PI) / 180,
                  endAngle: ((1 + this.num1) * Math.PI) / 180
                },
                style: {
                  stroke: '#fdf914',
                  fill: 'transparent',
                  lineWidth: 5
                },
                silent: true
              }
            },
            data: [0]
          }
        ]
      }
      return option
    },
    setOption2() {
      let option = {
        title: [
          {
            text: '',
            x: 'center',
            top: '55%',
            textStyle: {
              color: '#fdf914',
              fontSize: 18,
              fontWeight: '100'
            }
          },
          {
            text: this.num2 + '%',
            x: 'center',
            top: '40%',
            textStyle: {
              fontSize: '30',
              color: '#fdf914',
              fontFamily: 'Lato',
              foontWeight: '500'
            }
          }
        ],
        polar: {
          radius: ['55%', '65%'],
          center: ['50%', '50%']
        },
        angleAxis: {
          max: 100,
          show: false
        },
        radiusAxis: {
          type: 'category',
          show: true,
          axisLabel: {
            show: false
          },
          axisLine: {
            show: false
          },
          axisTick: {
            show: false
          }
        },
        series: [
          {
            name: '',
            type: 'bar',
            roundCap: true,
            barWidth: 60,
            showBackground: true,
            backgroundStyle: {
              color: 'rgba(66, 66, 66, .3)'
            },
            data: [this.num2],
            coordinateSystem: 'polar',

            itemStyle: {
              normal: {
                color: new echarts.graphic.LinearGradient(0, 1, 0, 0, [
                  {
                    offset: 1,
                    color: 'rgb(53, 255, 178)'
                  },
                  {
                    offset: 0.5,
                    color: 'rgb(255, 242, 53)'
                  },
                  {
                    offset: 0,
                    color: 'rgb(255, 104, 53)'
                  }
                ])
              }
            }
          },
          {
            type: 'gauge',
            name: '',
            radius: '80%',
            startAngle: '0',
            endAngle: '-359.99',
            splitNumber: '200',
            center: ['50%', '50%'],
            pointer: {
              show: false
            },
            title: {
              show: false
            },
            detail: {
              show: false
            },
            data: [
              {
                value: 95,
                name: ''
              }
            ],
            axisLine: {
              lineStyle: {
                width: 50,
                opacity: 0
              }
            },
            axisTick: {
              show: false
            },
            splitLine: {
              show: true,
              length: 13,
              lineStyle: {
                color: {
                  type: 'linear',
                  x: 1,
                  y: 0,
                  x2: 0,
                  y2: 0,
                  colorStops: [
                    {
                      offset: 0,
                      color: '#111'
                    },
                    {
                      offset: 0.5,
                      color: 'rgb(71, 255, 252)'
                    },
                    {
                      offset: 1,
                      color: '#111'
                    }
                  ],
                  globalCoord: false
                },
                width: 1,
                type: 'solid'
              }
            },
            axisLabel: {
              show: false
            }
          },
          {
            name: '',
            type: 'pie',
            startAngle: 90,
            radius: ['65%', '68%'],
            hoverAnimation: false,
            center: ['50%', '50%'],
            itemStyle: {
              normal: {
                labelLine: {
                  show: false
                },
                color: 'rgba(66, 66, 66, .4)',
                shadowBlur: 10,
                shadowColor: 'rgba(253, 249, 20, .3)'
              }
            },
            data: [
              {
                value: 100
              }
            ]
          },
          {
            name: '',
            type: 'pie',
            startAngle: 90,
            radius: ['62.5%', '64%'],
            hoverAnimation: false,
            center: ['50%', '50%'],
            itemStyle: {
              normal: {
                labelLine: {
                  show: false
                },
                color: 'rgba(66, 66, 66, .3)',
                shadowBlur: 10,
                shadowColor: 'rgba(253, 249, 20, .3)'
              }
            },
            data: [
              {
                value: 100
              }
            ]
          },
          {
            name: '',
            type: 'pie',
            startAngle: 90,
            radius: ['64.5%', '65.8%'],
            hoverAnimation: false,
            center: ['50%', '50%'],
            itemStyle: {
              normal: {
                labelLine: {
                  show: false
                },
                color: 'rgba(66, 66, 66, .2)',
                shadowBlur: 10,
                shadowColor: 'rgba(253, 249, 20, .3)'
              }
            },
            data: [
              {
                value: 100
              }
            ]
          },
          {
            name: '',
            type: 'pie',
            startAngle: 90,
            radius: ['66.5%', '67.5%'],
            hoverAnimation: false,
            center: ['50%', '50%'],
            itemStyle: {
              normal: {
                labelLine: {
                  show: false
                },
                color: 'rgba(66, 66, 66, .1)',
                shadowBlur: 10,
                shadowColor: 'rgba(253, 249, 20, .3)'
              }
            },
            data: [
              {
                value: 100
              }
            ]
          },
          {
            name: '',
            type: 'custom',
            coordinateSystem: 'none',
            renderItem: (params, api) => {
              return {
                type: 'arc',
                shape: {
                  cx: api.getWidth() / 2,
                  cy: api.getHeight() / 2,
                  r: (Math.min(api.getWidth(), api.getHeight()) / 2) * 0.545,
                  startAngle: ((0 + this.num2) * Math.PI) / 180,
                  endAngle: ((1 + this.num2) * Math.PI) / 180
                },
                style: {
                  stroke: '#fdf914',
                  fill: 'transparent',
                  lineWidth: 5
                },
                silent: true
              }
            },
            data: [0]
          }
        ]
      }
      return option
    },
    setOption3() {
      let option = {
        title: [
          {
            text: '',
            x: 'center',
            top: '55%',
            textStyle: {
              color: '#fdf914',
              fontSize: 18,
              fontWeight: '100'
            }
          },
          {
            text: this.num3 + '%',
            x: 'center',
            top: '40%',
            textStyle: {
              fontSize: '30',
              color: '#fdf914',
              fontFamily: 'Lato',
              foontWeight: '500'
            }
          }
        ],
        polar: {
          radius: ['55%', '65%'],
          center: ['50%', '50%']
        },
        angleAxis: {
          max: 100,
          show: false
        },
        radiusAxis: {
          type: 'category',
          show: true,
          axisLabel: {
            show: false
          },
          axisLine: {
            show: false
          },
          axisTick: {
            show: false
          }
        },
        series: [
          {
            name: '',
            type: 'bar',
            roundCap: true,
            barWidth: 60,
            showBackground: true,
            backgroundStyle: {
              color: 'rgba(66, 66, 66, .3)'
            },
            data: [this.num3],
            coordinateSystem: 'polar',

            itemStyle: {
              normal: {
                color: new echarts.graphic.LinearGradient(0, 1, 0, 0, [
                  {
                    offset: 1,
                    color: 'rgb(53, 255, 178)'
                  },
                  {
                    offset: 0.5,
                    color: 'rgb(255, 242, 53)'
                  },
                  {
                    offset: 0,
                    color: 'rgb(255, 104, 53)'
                  }
                ])
              }
            }
          },
          {
            type: 'gauge',
            name: '',
            radius: '80%',
            startAngle: '0',
            endAngle: '-359.99',
            splitNumber: '200',
            center: ['50%', '50%'],
            pointer: {
              show: false
            },
            title: {
              show: false
            },
            detail: {
              show: false
            },
            data: [
              {
                value: 95,
                name: ''
              }
            ],
            axisLine: {
              lineStyle: {
                width: 50,
                opacity: 0
              }
            },
            axisTick: {
              show: false
            },
            splitLine: {
              show: true,
              length: 13,
              lineStyle: {
                color: {
                  type: 'linear',
                  x: 1,
                  y: 0,
                  x2: 0,
                  y2: 0,
                  colorStops: [
                    {
                      offset: 0,
                      color: '#111'
                    },
                    {
                      offset: 0.5,
                      color: 'rgb(71, 255, 252)'
                    },
                    {
                      offset: 1,
                      color: '#111'
                    }
                  ],
                  globalCoord: false
                },
                width: 1,
                type: 'solid'
              }
            },
            axisLabel: {
              show: false
            }
          },
          {
            name: '',
            type: 'pie',
            startAngle: 90,
            radius: ['65%', '68%'],
            hoverAnimation: false,
            center: ['50%', '50%'],
            itemStyle: {
              normal: {
                labelLine: {
                  show: false
                },
                color: 'rgba(66, 66, 66, .4)',
                shadowBlur: 10,
                shadowColor: 'rgba(253, 249, 20, .3)'
              }
            },
            data: [
              {
                value: 100
              }
            ]
          },
          {
            name: '',
            type: 'pie',
            startAngle: 90,
            radius: ['62.5%', '64%'],
            hoverAnimation: false,
            center: ['50%', '50%'],
            itemStyle: {
              normal: {
                labelLine: {
                  show: false
                },
                color: 'rgba(66, 66, 66, .3)',
                shadowBlur: 10,
                shadowColor: 'rgba(253, 249, 20, .3)'
              }
            },
            data: [
              {
                value: 100
              }
            ]
          },
          {
            name: '',
            type: 'pie',
            startAngle: 90,
            radius: ['64.5%', '65.8%'],
            hoverAnimation: false,
            center: ['50%', '50%'],
            itemStyle: {
              normal: {
                labelLine: {
                  show: false
                },
                color: 'rgba(66, 66, 66, .2)',
                shadowBlur: 10,
                shadowColor: 'rgba(253, 249, 20, .3)'
              }
            },
            data: [
              {
                value: 100
              }
            ]
          },
          {
            name: '',
            type: 'pie',
            startAngle: 90,
            radius: ['66.5%', '67.5%'],
            hoverAnimation: false,
            center: ['50%', '50%'],
            itemStyle: {
              normal: {
                labelLine: {
                  show: false
                },
                color: 'rgba(66, 66, 66, .1)',
                shadowBlur: 10,
                shadowColor: 'rgba(253, 249, 20, .3)'
              }
            },
            data: [
              {
                value: 100
              }
            ]
          },
          {
            name: '',
            type: 'custom',
            coordinateSystem: 'none',
            renderItem: (params, api) => {
              return {
                type: 'arc',
                shape: {
                  cx: api.getWidth() / 2,
                  cy: api.getHeight() / 2,
                  r: (Math.min(api.getWidth(), api.getHeight()) / 2) * 0.545,
                  startAngle: ((0 + this.num3) * Math.PI) / 180,
                  endAngle: ((1 + this.num3) * Math.PI) / 180
                },
                style: {
                  stroke: '#fdf914',
                  fill: 'transparent',
                  lineWidth: 5
                },
                silent: true
              }
            },
            data: [0]
          }
        ]
      }
      return option
    }
  }
}
</script>

<style lang='scss' scoped>
#myChart1 {
  width: 100%;
  height: 100%;
}
</style>